package com.lkd.controller;


import com.lkd.dto.RegionDto;
import com.lkd.entity.Region;
import com.lkd.service.AreaService;
import com.lkd.service.RegionService;
import com.lkd.vo.PageBean;
import com.lkd.vo.RegionVo;
import com.lkd.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 运营区域 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-08-20
 */
@RestController
public class RegionController {
    @Autowired
    private RegionService regionService;
    @GetMapping("/api/vm-service/region/search")
    public Result findAreaByPage(
            String name,
            @RequestParam(defaultValue = "1") Integer pageIndex,
            @RequestParam(defaultValue = "10")Integer pageSize
    ){
        PageBean<RegionVo> pageBean=regionService.findAreaByPage(name,pageIndex,pageSize);
        return Result.success (pageBean);
    }

    //新增区域
    @PostMapping("/api/vm-service/region")
    public Result addRegion(@RequestBody RegionDto regionDto){
        boolean save = regionService.addRegion (regionDto);
        return Result.success (save);
    }
    //修改区域
    @PutMapping("/api/vm-service/region")
    public Result updateRegion(@RequestBody RegionDto regionDto){
        boolean b = regionService.updateRegion (regionDto);
        return Result.success (b);
    }

}
